



import React,{PureComponent,Component} from 'react'


class Demo extends Component{
  render(){
    return <h1>demo组件</h1>
  }

  componentDidMount(){
    this.timeId = setInterval(() => {
      console.log(1);
    }, 1000);
  }
  componentWillUnmount() {
    console.log("Demo组件卸载");
    clearInterval(this.timeId);
  }
}




class App extends Component{
  state={
   istrue:true
  }

  handleClick = ()=>{
    this.setState({
      istrue:false
    })
  }
  render(){
   return (
    <div>
     {this.state.istrue ? <Demo></Demo> : ""}
    <button onClick={this.handleClick}>卸载组件</button>
  </div>
   )
  }
}



export default App;

